﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Donal.Xms.Common
{
    /// <summary>
    /// 正则验证类
    /// </summary>
    public class Regexlib
    {
        public static bool IsValidEmail(string strIn)
        {
            return Regex.IsMatch(strIn, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
        }

        public static bool IsValidMobile(string strIn)
        {
            return Regex.IsMatch(strIn, @"^[1]+[3,5,7,8]+\d{9}$");
        }

        public static bool IsValidNumber(string strIn)
        {
            return Regex.IsMatch(strIn, @"^[\d]+$");
        }

        public static bool IsValidTelPhone(string strIn)
        {
            return Regex.IsMatch(strIn, @"^(\d{3,4}-)?\d{6,8}$");
        }

        public static bool IsValidUserName(string strIn)
        {
            return Regex.IsMatch(strIn, "^[A-Za-z0-9_]{3,50}$");
        }
    }
}
